package zlx.springcloud.config;

import org.springframework.cloud.gateway.route.RouteLocator;
import org.springframework.cloud.gateway.route.builder.RouteLocatorBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class GatewayConfig {
    /**
     * 配置了一个为path_zlx_route的路由规则，
     * 当地址访问http://localhost:9527/guonei时
     * 会自动转发到地址：http://news.baidu.com/guoneihui'dui
     * @param builder
     * @return
     */
    @Bean
    public RouteLocator customeRouteLocator(RouteLocatorBuilder builder){
        RouteLocatorBuilder.Builder  routes= builder.routes();
        routes.route("path_zlx_route",r->r.path("/guonei").uri("http://news.baidu.com/guonei")).build();
        return routes.build();
    }
    @Bean
    public RouteLocator customeRouteLocator1(RouteLocatorBuilder builder){
        RouteLocatorBuilder.Builder  routes= builder.routes();
        routes.route("path_zlx_route1",r->r.path("/guoji").uri("http://news.baidu.com/guoji")).build();
        return routes.build();
    }
}
